<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>BOM</title>
</head>
<body>
  <p>窗口 <span>关闭</span>状态</p>
  <button onclick="openWin()">打开窗口</button>
  <button onclick="closeWin()">关闭窗口</button>
</body>
<script type="text/javascript">
  var win,
      oStatus = document.getElementsByTagName("span")[0];
  
  function openWin(){
    win = window.open('www.baidu.com', '', 'width=300, heihgt=300, top=200, left=500');
    checkStatus();
  }

  function closeWin(){
    win.close();
    checkStatus();
  }

  function checkStatus(){
    if(win.closed){
      oStatus.innerHTML = "关闭";
    }else{
      oStatus.innerHTML = "打开";
    }
  }
</script>
</html>